/*     */ package com.qmsk.business.informake.infoCustomer.controller;
/*     */ 
/*     */ import com.qmsk.business.manage.cust.dao.CustDAO;
/*     */ import com.qmsk.business.shopList.ShopMap;
/*     */ import com.utils.basic.MapUtils;
/*     */ import com.utils.basic.ObjectComm;
/*     */ import com.utils.gson.in.GsonHeadManyRows;
/*     */ import com.utils.gson.in.GsonHeadOneRow;
/*     */ import com.utils.gson.in.ParserDataSetJson;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.http.HttpGsonPtResponseUtils;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"ptInfoCust"})
/*     */ public class InfoCustomerController
/*     */ {
/*  34 */   private static final Logger logger = Logger.getLogger(InfoCustomerController.class);
/*     */ 
/*     */   @Autowired
/*     */   private CustDAO custDao;
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/infoId/{infoId}/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListShopId(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId, @PathVariable("infoId") String infoId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  54 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  56 */       String sData = "";
/*  57 */       String sUrl = "ptInfoCust/find/shopId/" + 
/*  58 */         ShopMap.getOutIdOfShopId(shopId) + "/infoId/" + infoId + 
/*  59 */         "/" + nPageIdx + "/" + nPageSize;
/*  60 */       GsonEbRst rst = HttpGsonPtResponseUtils.getPtEbRst(sUrl, sData, 
/*  61 */         response);
/*  62 */       if ((rst != null) && (rst.getState() == 0)) {
/*  63 */         ResponseUtils.setResponseResult(rst, response);
/*  64 */         return; }
/*  65 */       ResponseUtils.setSqlResultResponse(0, 
/*  66 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/*  67 */         response);
/*     */     }
/*     */     catch (Exception e) {
/*  70 */       logger.error(e);
/*  71 */       ResponseUtils.setErrorMsgResponse(
/*  72 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"insert/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId)
/*     */   {
/*  89 */     String sGsonInData = RequestUtils.getString(request, "data");
/*     */     try {
/*  91 */       ParserDataSetJson p = ParserDataSetJson.fromString(sGsonInData);
/*  92 */       if ((p != null) && (p.isExistsInsertRows())) {
/*  93 */         for (int i = 0; i < p.getListInsertRows().size(); ++i) {
/*  94 */           GsonHeadOneRow g = (GsonHeadOneRow)p.getListInsertRows().get(i);
/*  95 */           Long custId = ObjectComm.objectToLong(g
/*  96 */             .getValueOfName("CustId"));
/*  97 */           Long outId = this.custDao.getOutId(custId);
/*  98 */           if (outId != null)
/*  99 */             g.autoAddHeadData("CustId", outId);
/*     */           else {
/* 101 */             p.getListInsertRows().remove(i);
/*     */           }
/*     */         }
/*     */       }
/* 105 */       String sData = "data=" + p.objectToJsonStr();
/* 106 */       String sUrl = "ptInfoCust/insert/shopId/" + 
/* 107 */         ShopMap.getOutIdOfShopId(shopId);
/* 108 */       GsonEbRst rst = HttpGsonPtResponseUtils.postPtEbRst(sUrl, sData, 
/* 109 */         response);
/* 110 */       if ((rst != null) && (rst.getState() == 0)) {
/* 111 */         ResponseUtils.setResponseResult(rst, response);
/* 112 */         return; }
/* 113 */       ResponseUtils.setSqlResultResponse(0, 
/* 114 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 115 */         response);
/*     */     }
/*     */     catch (Exception e) {
/* 118 */       logger.error(e);
/* 119 */       ResponseUtils.setErrorMsgResponse(
/* 120 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 121 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"insert/shopId/{shopId}/all"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insertAll(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId)
/*     */   {
/*     */     try
/*     */     {
/* 139 */       Map params = new HashMap();
/* 140 */       MapUtils.addToMap(params, "shopId", shopId);
/* 141 */       MapUtils.addPercentToMap(params, "mp", 
/* 142 */         RequestUtils.getString(request, "mp"));
/* 143 */       MapUtils.addPercentToMap(params, "custName", 
/* 144 */         RequestUtils.getString(request, "name"));
/* 145 */       MapUtils.addPercentToMap(params, "tel", 
/* 146 */         RequestUtils.getString(request, "tel"));
/* 147 */       MapUtils.addPercentToMap(params, "addr", 
/* 148 */         RequestUtils.getString(request, "addr"));
/* 149 */       MapUtils.addToMap(params, "dtBirthBegin", 
/* 150 */         RequestUtils.getDate(request, "dtBirthBegin"));
/* 151 */       MapUtils.addToMap(params, "dtBirthEnd", 
/* 152 */         RequestUtils.getDate(request, "dtBirthEnd"));
/* 153 */       MapUtils.addToMap(params, "custId", 
/* 154 */         RequestUtils.getInt(request, "custId"));
/*     */ 
/* 156 */       GsonHeadManyRows m = this.custDao.getCustOutIdOfShopId(params);
/* 157 */       if (m.isExistsData()) {
/* 158 */         Long infoId = RequestUtils.getLong(request, "infoId");
/* 159 */         String sData = "data=" + m.objectToJsonStr() + "&infoId=" + infoId;
/* 160 */         String sUrl = "ptInfoCust/insert/shopId/" + 
/* 161 */           ShopMap.getOutIdOfShopId(shopId) + "/all";
/* 162 */         GsonEbRst rst = HttpGsonPtResponseUtils.postPtEbRst(sUrl, 
/* 163 */           sData, response);
/* 164 */         if ((rst != null) && (rst.getState() == 0))
/* 165 */           ResponseUtils.setResponseResult(rst, response);
/*     */         else
/* 167 */           ResponseUtils.setSqlResultResponse(0, 
/* 168 */             RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 169 */             response);
/*     */       }
/*     */     }
/*     */     catch (Exception e) {
/* 173 */       logger.error(e);
/* 174 */       ResponseUtils.setErrorMsgResponse(
/* 175 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 176 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"edit/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void edit(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId)
/*     */   {
/* 193 */     String sGsonInData = RequestUtils.getString(request, "data");
/*     */     try {
/* 195 */       String sData = "data=" + sGsonInData;
/* 196 */       String sUrl = "ptInfoCust/edit/shopId/" + 
/* 197 */         ShopMap.getOutIdOfShopId(shopId);
/* 198 */       GsonEbRst rst = HttpGsonPtResponseUtils.postPtEbRst(sUrl, sData, 
/* 199 */         response);
/* 200 */       if ((rst != null) && (rst.getState() == 0)) {
/* 201 */         ResponseUtils.setResponseResult(rst, response);
/* 202 */         return; }
/* 203 */       ResponseUtils.setSqlResultResponse(0, 
/* 204 */         RequestUtils.getSqlUpdateDataErrorMessage(request), 
/* 205 */         response);
/*     */     }
/*     */     catch (Exception e) {
/* 208 */       logger.error(e);
/* 209 */       ResponseUtils.setErrorMsgResponse(
/* 210 */         RequestUtils.getSqlUpdateDataErrorMessage(request) + ":" + 
/* 211 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"del/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId)
/*     */   {
/* 228 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 230 */       String sData = "id=" + id;
/* 231 */       String sUrl = "ptInfoCust/del/shopId/" + 
/* 232 */         ShopMap.getOutIdOfShopId(shopId);
/* 233 */       GsonEbRst rst = HttpGsonPtResponseUtils.postPtEbRst(sUrl, sData, 
/* 234 */         response);
/* 235 */       if ((rst != null) && (rst.getState() == 0)) {
/* 236 */         ResponseUtils.setResponseResult(rst, response);
/* 237 */         return; }
/* 238 */       ResponseUtils.setSqlResultResponse(0, 
/* 239 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 240 */         response);
/*     */     }
/*     */     catch (Exception e) {
/* 243 */       logger.error(e);
/* 244 */       ResponseUtils.setErrorMsgResponse(
/* 245 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 246 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"del/shopId/{shopId}/all"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void deleteInfoIdOfAll(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId)
/*     */   {
/* 263 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 265 */       String sData = "infoId=" + id;
/* 266 */       String sUrl = "ptInfoCust/del/shopId/" + 
/* 267 */         ShopMap.getOutIdOfShopId(shopId) + "/all";
/* 268 */       GsonEbRst rst = HttpGsonPtResponseUtils.postPtEbRst(sUrl, sData, 
/* 269 */         response);
/* 270 */       if ((rst != null) && (rst.getState() == 0)) {
/* 271 */         ResponseUtils.setResponseResult(rst, response);
/* 272 */         return; }
/* 273 */       ResponseUtils.setSqlResultResponse(0, 
/* 274 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 275 */         response);
/*     */     }
/*     */     catch (Exception e) {
/* 278 */       logger.error(e);
/* 279 */       ResponseUtils.setErrorMsgResponse(
/* 280 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 281 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.informake.infoCustomer.controller.InfoCustomerController
 * JD-Core Version:    0.5.3
 */